Page({
  data: {
    pageTotal: '',
    total: '',
    pageSize: 5,
    current: 1,
    visitorList: '',
    isEmpty: true
  },
  goPassport () {
    wx.navigateTo({
      url: '/visitor_pkg/pages/passport/index'
    })
  },
  onLoad () {
    this.getVisitorList()
  },
  async getVisitorList () {
    const list = this.data.visitorList
    const {
      code,
      data: { pageTotal, total, rows }
    } = await wx.http.get('/visitor', { pageSize: this.data.pageSize, current: this.data.current })
    if (code !== 10000) return
    if (rows.length) {
      this.setData({
        isEmpty: false
      })
    }
    this.setData({
      pageTotal,
      total,
      visitorList: [...list, ...rows]
    })
  },
  getMoreVisitor () {
    let current = (this.data.current += 1)
    console.log(current)
    this.setData({
      current
    })
    this.getVisitorList()
  }
})
